import com.cos.mb2.dao.EmpDao;
import com.cos.mb2.entity.Emp;
import com.cos.mb2.util.MybatisUtils;
import org.junit.Test;

/**
 * @author: COS
 * @time: 2022/5/31 16:11
 * @description:
 */
public class Demo3 {
    @Test
    public void t1(){
        EmpDao mapper = MybatisUtils.getMapper(EmpDao.class);
//        System.out.println(mapper.getAll());
        Emp e = new Emp();
        e.setEno(1225);
        e.setEname("小狗");
//        e.setEsex("妖");
//        mapper.getEmpByKey(e).stream().forEach(System.out::println);
        System.out.println(mapper.updateEmp(e));
        MybatisUtils.commit();
    }



    public static void main(String[] args) {
        Emp e = new Emp();
        e.setEname("小白");
//        e.setEsex("女");
        query(e);
    }


    public static void query(Emp e){
        String sql ="select * from emp where 1=1 ";

        if (e.getEname()!=null) {
            sql+= " and ename like %"+e.getEname()+"%";
        }
        if (e.getEsex()!=null) {
            sql+= " and esex ="+e.getEsex();
        }
        System.out.println(sql);

    }

}
